/**
 * 
 */
package fr.ants.controller.command;

import fr.ants.controller.clock.Clock;

/**
 * Command to run or to put in pause the simulation.
 * 
 * @author Guillaume Ruscassies
 * 
 */
public class PlayPauseCommand implements Command {
	/**
	 * Clock.
	 */
	private final Clock clock;

	/**
	 * Build.
	 * 
	 * @param clock
	 *            clock
	 */
	public PlayPauseCommand(final Clock clock) {
		this.clock = clock;
	}

	@Override
	public void execute() {

		if (clock.isRunning()) {
			clock.pause();
		} else if (clock.isPaused()) {
			clock.restart();
		} else {
			clock.start();
		}
	}
}